<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>数据更新</title>
<s:set name="type_name" value="%{@com.japp.tools.common.SelectVal@getData(data.type)}"></s:set>
<s:set name="date_type" value="%{@com.japp.tools.common.SelectVal@getDataToDateType(data.date_type)}"></s:set>
<s:include value="/app_common/common.jsp"></s:include>
<s:include value="/app_common/uploadify.jsp"></s:include>
<%--是否是新增 --%>
<!-- 表单验证start -->
<script src="<s:property value='webctx'/>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<s:property value='webctx'/>/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->
<!-- 用户选择start -->
<script type="text/javascript" src="<s:property value='webctx'/>/app_common/userPopup/queryUser.js"></script>
<!-- 用户选择end -->
</head>
<body style="width: 100%">
<form name="form2" id="form2" method="post" target="frmright">
	<div class="box2" style="width: 750px" panelTitle="<s:property value="type_name"/>数据<s:property value="data.id==0?'新增':'修改'"/>(<s:property value="date_type"/>)">
		<s:hidden name="data.type" id="data_type"></s:hidden>
		<s:hidden name="data.data_type"></s:hidden>
		<s:hidden name="data.date_type"></s:hidden>
		<s:if test="!(data.code==null||data.code=='')">
			<%--所属人编码 --%>
			<s:hidden name="data.submit_ucode"></s:hidden>
			<%--所属人名称 --%>
			<s:hidden name="data.submit_uname"></s:hidden>
			<%--所属分部--%>
			<s:hidden name="data.submit_dpid"></s:hidden>
			<%--所属分部名称--%>
			<s:hidden name="data.submit_dpname"></s:hidden>
		</s:if>
		<s:else>
			<%--所属人编码 --%>
			<s:hidden name="data.submit_ucode" value="%{#session.u_code}"></s:hidden>
			<%--所属人名称 --%>
			<s:hidden name="data.submit_uname" value="%{#session.u_name}"></s:hidden>
			<%--所属分部--%>
			<s:hidden name="data.submit_dpid" value="%{#session.userltd}"></s:hidden>
			<%--所属分部名称--%>
			<s:hidden name="data.submit_dpname" value="%{#session.userltdname}"></s:hidden>
		</s:else>
			<s:hidden name="data.id" id="id"></s:hidden>
			<table class="tableStyle" style="line-height: 30px;width: 750px" formMode="transparent">
				<tr>
					<td><s:property value="type_name"/>数据编号:</td>
					<td style="color: red;">
						<s:property value="data.code==null||data.code==''?'自动生成':data.code"/>
					</td>
					<td>所属部门：</td>
					<td>
						<s:if test="!(data.code==null||data.code=='')"><s:property value="data.submit_dpname"/></s:if>
						<s:else><s:property value="%{#session.userltdname}"/></s:else>
					</td>
					<td><s:property value="type_name"/>数据科目：</td>
					<td>
						<select name="data.data_ctype" selectedValue="<s:property value='data.data_ctype'/>" prompt="请选择" data='<s:property value="%{map['sel_'+data.data_type]}"/>' class="validate[required]"></select>
						<span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td><s:property value="type_name"/>数据填报人:</td>
					<td>
						<s:property value="%{data.code==null||data.code==''?#session.u_name:data.submit_uname}"/>
					</td>
					<td><s:property value="type_name"/>数据金额（万）/数量(个):</td>
					<td>
						<input type="text" id="moneys" name="data.moneys" value="<s:property value='data.moneys'/>" class="validate[required,custom[onlyNumberWide]]" maxlength="9">
						<span class="star">*</span>
					</td>
					<s:if test="data.type==1">
					<td>费用报销人:</td>
					<td>
						<s:hidden id="user_code" name="data.bxr_ucode"></s:hidden>
						<input type="text" id="user_name"  name="data.bxr_uname" onclick="queryUserAll('1')" style="cursor: pointer;" class="query_user"  value="<s:property value="data.bxr_uname" />"/><span class="star">*</span>
					</td>
					</s:if>
					<s:else>
						<td></td>
						<td></td>
					</s:else>
				</tr>
				<tr>
					<td><s:property value="type_name"/>数据明细:</td>
					<td colspan="5">
						<textarea name="data.remark" style="width: 300px;height: 60px"><s:property value="data.remark"/></textarea>
					</td>
				</tr>
				<tr>
					<td style="padding: 0 8px;">附件上传：</td>
					<td align="left" style="padding: 2px 6px;" colspan="5">
						<div style="color: red;">小提示：附件允许最大上传文件数为5个</div>
						<div id="full"></div>
						<div id="allShow"></div>
						<div id="show"></div>
						<input type="file" keepDefaultStyle="true" name="uploadify" id="strutsUploadFile" />
						<br />
					</td>
				</tr>
				<tr>
					<td>提交时间:<s:property value=""/></td>
					<td>
						<s:property value="%{data.code==null||data.code==''?'自动生成':data.submit_date}"/>
					</td>
					<td>提交人编码</td>
					<td>
						<s:property value="%{data.code==null||data.code==''?#session.u_code:data.submit_ucode}"/>
					</td>
					<td>提交人名称</td>
					<td>
						<s:property value="%{data.code==null||data.code==''?#session.u_name:data.submit_uname}"/>
					</td>
				</tr>
				<tr>
					<td colspan="6">
					<input type="button" onclick="back()" value="返回" />&nbsp;&nbsp;
					<input type="button" id="btn1" onclick="checkSubmit()" value="提交" />
					</td>
				</tr>
			</table>
	</div>
	<div class="clear"></div>
</form>
</body>
<script type="text/javascript">
var status = "<s:property value='data.id' />";
var data_type = $('#data_type').val();
var id = status;
function checkSubmit(){
	var actionUrl;
	var valid = $("#form2").validationEngine({returnIsValid: true});
	if(data_type==1&&valid&&!$.trim($('#user_name').val())){
		top.Dialog.alert('请选择数据填报人!');
		valid = false;
	}
	if(!valid){
		return false;
	}
	if(status=="0"){
		actionUrl = webctx+"/reality/data_insertDataById.action";
		isback = true;
		back_url = webctx+"/reality/data_queryData.action";
	}else{
		actionUrl = webctx+"/reality/data_updateDataById.action";
	}
	var actionData = $("#form2").serialize();
	//return false;
	showProgressBar();
	$.ajax({
		url:actionUrl,
		data:actionData,
		type : "post",
		cache : false,
		dataType : 'text',
		success : function(data) {
			if(data!=0){
				gl_conId = data;
				$('#strutsUploadFile').uploadifySettings('scriptData',{'conId':data,'fileFolder':'TB_DATA'}); 
				$('#strutsUploadFile').uploadifyUpload();
				if(id==0){
					var it = setInterval(function(){
						if(isover||$('#strutsUploadFileQueue').children().length==0){
							clearInterval(it);
							closeProgress();
							alert('操作成功!');
							window.location = webctx+"/reality/data_queryData.action?data.type=<s:property value='data.type'/>&data.data_type=<s:property value='data.data_type'/>&data.date_type=<s:property value='data.date_type'/>";
						}
					},1000);
				}else{
					closeProgress();
					alert("操作成功!");
					selectFiles(data,'TB_DATA');
				}
			}else{
				alert('操作失败!');
				closeProgress();
			}
		}
	});
}
function back(){
	top.Dialog.confirm("确认返回？",function(){
		showProgressBar();
		window.location = webctx+"/reality/data_queryData.action?data.type=<s:property value='data.type'/>&data.data_type=<s:property value='data.data_type'/>&data.date_type=<s:property value='data.date_type'/>";
	});
}
$(function(){
	if(status!=0)selectFiles(status,"TB_DATA");
		//提示
	$('#moneys').bind('focus',function(){
		if(nullBooleanNumber($(this).val())){
			$(this).val('');
		}
	}).bind('blur',function(){
		if(nullBooleanNumber($(this).val())){
			$(this).val('0.0');
		}
	});
});
</script>
</html>